package com.xb.service.imp;

import com.xb.entity.MedicalExamination;
import com.xb.entity.OutpatientQueue;
import com.xb.entity.User;
import com.xb.mapper.MedicalExaminationMapper;
import com.xb.mapper.OutpatientQueueMapper;
import com.xb.mapper.UserMapper;
import com.xb.service.IOutpatientQueueService;
import com.xb.util.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * entityService业务层处理
 */
@Service
public class OutpatientQueueServiceImp implements IOutpatientQueueService {
    @Resource
    private OutpatientQueueMapper outpatientQueueMapper;
    @Resource
    private UserMapper userMapper;
    @Resource
    private MedicalExaminationMapper examinationMapper;

    @Override
    public List<OutpatientQueue> selectAllOutpatientQueueList(HttpSession session) {
        String email = (String) session.getAttribute("email");
        User user = userMapper.selectUserByEmail(email);
        return outpatientQueueMapper.selectAllOutpatientQueueList(user.getId());
    }

    @Override
    public Result getMedicalExamination(String prescriptionNum) {
        Result result = new Result();
        try {
            MedicalExamination medicalExamination = examinationMapper.selectMedicalExaminationByPrescriptionNum(prescriptionNum);
            if (medicalExamination != null) {
                result.setData(medicalExamination);
            } else {
                result.setMessage("更新失败！");
            }
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            result.setStatus(Result.RESPONSE_EXCEPTION);
            result.setMessage("请联系管理员");
            return result;
        }

    }
}
